﻿@*
//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://diego2098.gitee.io/thingsgateway-docs/
//  QQ群：605534569
//------------------------------------------------------------------------------
*@

@page "/admin/oplog"
@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Admin.Application;
 
@namespace ThingsGateway.Admin.Blazor
@attribute [Authorize]
@inject UserResoures UserResoures
@inherits BaseComponentBase
@layout MainLayout
<AppDataTable @ref="_datatable" TItem="SysOperateLog" SearchItem="OperateLogPageInput" 
              AddItem="object" EditItem="object" IsShowSelect=false
              SearchModel="@_search" IsShowOperCol=true
              QueryCallAsync="QueryCallAsync"
                IsShowDetailButton IsShowQueryButton IsShowSearchKey>
    <SearchTemplate>

        <MMenu CloseOnContentClick="false" OffsetY Context="menu">
            <ActivatorContent>
                <MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 "
                            Value="context.StartTime.Value.ToDefaultDateTimeFormat(_initTimezone.TimezoneOffset)"
                @attributes="menu.Attrs" Outlined Label=@context.Description(x => x.StartTime) />
            </ActivatorContent>
            <ChildContent>
                <AppDateTimePicker @bind-Value="context.StartTime"></AppDateTimePicker>
            </ChildContent>
        </MMenu>

        <MMenu CloseOnContentClick="false" OffsetY Context="menu">
            <ActivatorContent>
                <MTextField Dense Readonly Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 "
                            Value="context.EndTime.Value.ToDefaultDateTimeFormat(_initTimezone.TimezoneOffset)" Clearable
                @attributes="menu.Attrs" Outlined Label=@context.Description(x => x.EndTime) />
            </ActivatorContent>
            <ChildContent>
                <AppDateTimePicker @bind-Value="context.EndTime"></AppDateTimePicker>
            </ChildContent>
        </MMenu>

        <MSelect Style="max-width:200px;"
                 Class="my-1 mx-2 " @bind-Value="context.Category"
                  Outlined Label=@context.Description(x => x.Category)
                 Items=@(_categoryFilters) Clearable
                 MenuProps="@(props => { props.Bottom = true; props.OffsetY = true; })"
                 ItemText=@((u) =>u.Key)
                 ItemValue=@(u => u.Value)
                 HideDetails="true" Height="30"
                  Dense>
        </MSelect>
        <MSelect Style="max-width:200px;"
                 Class="my-1 mx-2 " @bind-Value="context.ExeStatus"
                  Outlined Label=@context.Description(x => x.ExeStatus)
                 Items=@(_exeStatus) Clearable
                 MenuProps="@(props => { props.Bottom = true; props.OffsetY = true; })"
                 ItemText=@((u) =>u.Key)
                 ItemValue=@(u => u.Value)
                 HideDetails="true" Height="30"
                  Dense>
        </MSelect>
        <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1  mx-2 " @bind-Value="context.Account"
                        Outlined Label=@context.Description(x => x.Account) />

    </SearchTemplate>
    <OtherToolbarTemplate>
        @if (@UserResoures.IsHasButtonWithRole("sysoplogclear"))
        {
            <MButton Color="error" Class="mx-2 my-1" OnClick=@(ClearClick)>清空</MButton>
        }
        <MMenu OffsetY Context="menu">
            <ActivatorContent>
                <MButton @attributes="@menu.Attrs" Color="primary"
                         Class="my-1  mx-2 ">
                    导出
                    <AppChevronDown></AppChevronDown>
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MList>
                    <MListItem OnClick="()=>DownExportAsync()">导出全部</MListItem>
                     <MListItem OnClick="()=>DownExportAsync(_search)">导出搜索项</MListItem>
                </MList>

            </ChildContent>
        </MMenu>

    </OtherToolbarTemplate>
</AppDataTable>



